package leetcode.offer;


import algorithm.TreeNode;

/**
 * @author cyt
 * @create 2020-08-18 17:53
 */
public class offer55 {
    public static void main(String[] args) {
    }
    boolean flag = true;

    public boolean isBalanced(TreeNode root) {
        high(root);
        return flag;
    }
    int high(TreeNode root) {
        if (root == null) {
            return 0;
        }
        int left = high(root.left);
        int right = high(root.right);
        if (Math.abs(left - right) > 1) {
            flag = false;
        }
        return Math.max(left, right) + 1;
    }

}
class TreeNode55 {
    int val;
    TreeNode55 left;
    TreeNode55 right;

    TreeNode55(int x) {
        val = x;
    }
}




